using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class forums_controls_usercp_pm_pmthrobber : Controls.DataManagerUserControl
{
    protected override void ItemChanged()
    {
        Refresh();
    }

    public void Refresh()
    {
        pnlMessages.Visible = false;
        if (CurrentUser != null)
        {
            if (DAL.PrivateMessages.UserHasNewMessages(CurrentUser))
            {
                DAL.PrivateMessage myMessage = DAL.PrivateMessages.GetNewestUnreadMessageByUser(CurrentUser);
                if (myMessage != null)
                {
                    pnlMessages.Visible = true;
                    lnkMsg.NavigateUrl = "~/forums/usercp.aspx?readpm=" + myMessage.ID;
                }
            }
        }
    }

    protected override void UserLoggedOut(object sender, EventArgs e)
    {
        pnlMessages.Visible = false;
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        CurrentUser = Managers.UserLoginManager.CurrentUser;
    }
}
